#include "headfiles.h"

using namespace std;

int main(int argc, char **argv) {
    if (argc != 4) {
        cout << "Usage: " << argv[0] << " file orig_str new_str" << endl;
        return 0;
    }

    string file_name(argv[1]);
    string orig_str(argv[2]);
    string new_str(argv[3]);

    ifstream fs;
    fs.open(file_name.c_str(), fstream::in | fstream::binary);
    if (!fs.is_open()) {
        cout << "File " << file_name << " open error!" << endl;
        return 1;
    }

    string str;
    fs.seekg(0, ios::end);
    str.resize(fs.tellg());
    fs.seekg(0, ios::beg);
    fs.read(&str[0], str.size());
    fs.close();

    cout << "Original string is: " << endl;
    cout << str << endl;

    strReplace(str, orig_str, new_str);

    cout << "Changed string is: " << endl;
    cout << str << endl;

    return 0;
}

